﻿#region Opis pliku
//-----------------------------------------------------------------------------
// Barracks.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace pogra
{
    /// <summary>
    /// Baraki, produkuje się tu ludzi.
    /// </summary>
    class Barracks : Buildings
    {
        List<Unit> teamlist;
        Texture2D tanktexA;
        private int counter = 0;
        public static int kosztBudowy = 1500;

        public Barracks(Vector2 pos, float rotation, int team, List<Unit> teamlist, List<Unit> enemyteam, Texture2D tanktexA, Texture2D factorytex, Texture2D particletexture) :
            base(pos, rotation, team, enemyteam, factorytex)
        {
            kosztProdukcji = 100;
            hp = 100;
            amountToBulid = 00;
            timeOfConstruction = 6000;
            spawninterval = 1500;
            this.teamlist = teamlist;
            this.tanktexA = tanktexA;
            this.texture = factorytex;
            this.particletexture = particletexture;
        }

        protected override void WorkingState(TimeSpan time)
        {

            if (amountToBulid > 0 && this.time > spawninterval)
            {
                amountToBulid--;
                Random random = new Random();
                Grunt temp = new Grunt(position, rotation/*(float)(new Random().NextDouble() * Math.PI * 2)*/, team, tanktexA, particletexture, enemyteam, 0.1f);
                temp.setGoalPosition(new Point((int)(position.X + random.Next(0, 100) + Math.Cos(rotation) * 200), (int)(position.Y + random.Next(0, 100) + Math.Sin(rotation) * 200)));
                teamlist.Add(temp);

                counter++;
                this.time = 0;
            }
            base.WorkingState(time);

        }
    }
}
